
<script>
	import {
		init
	} from "@/shopro";
	export default {
		onLaunch(options) {
			init(options);
			this.getLogin()
		},
		methods:{
			getLogin() {
				uni.login({
					provider: "weixin",
					success: (res) => {
						console.log(res);
						// 获取微信登录的授权码
						var code = res.code
						//在写发送request请求，
						this.$http('user.userLogin', {
							code
						}).then(res => {
							if (res.code === 1) {
								console.log(res)
								let userInfo = res.data.userinfo;
								this.$store.commit('userInfo', userInfo);
								uni.setStorageSync("token", userInfo.token);
								uni.setStorageSync("isLogin", true);
								// this.$store.commit('isLogin', true);
							}
						});
					}
				})
			},
		}
	};
</script>

<style lang="scss">
	@import 'static/style/index.scss';
</style>
